<template>
  <div class="basic_info">
    <div>
      <div class="info_operation_btn">
        <p>帮助中心</p>
      </div>
      <div class="info_content_div">
        <div
          @click="toDetails(item)"
          v-for="(item, index) in listData.slice((currentPage - 1) * pagesize, currentPage * pagesize)"
          :key="index"
        >
          <p>{{ item.name }}</p>
          <p>
            <span>{{ item.content }}</span>
            <span>{{ item.date }}</span>
          </p>
        </div>
      </div>
      <div class="table_pagination">
        <div class="pagination_div">
          <el-pagination
            background
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[20, 50, 100, 200]"
            :page-size="pagesize"
            layout="jumper, prev, pager,next, sizes"
            :total="listData.length"
          >
          </el-pagination>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  name: 'helpCenter',
  computed: {
    ...mapGetters(['name']),
  },
  created() {
    for (let i = 0; i < 30; i++) {
      this.listData.push({
        name: '新手导航' + (i + 1),
        content: '新手导航操作指引。',
        date: '2021-07-10 09:25',
      })
    }
  },
  data() {
    return {
      listData: [],
      pagesize: 20, //每页的数据条数
      currentPage: 1, //默认开始页面
    }
  },
  methods: {
    // 跳转至详情
    toDetails(item) {
      this.$router.push({
        path: '/home/helpCenterDetails',
        query: {
          name: item.name,
        },
      })
    },
    // 获取每页几条数据
    handleSizeChange(val) {
      this.pagesize = val
    },
    // 获取当前第几页
    handleCurrentChange(val) {
      this.currentPage = val
    },
  },
}
</script>

<style lang="scss" scoped>
.basic_info {
  width: 100%;
  height: calc(100vh - 110px);
  background: #f0f2f5;
  box-sizing: border-box;
  padding: 0 8px 8px;
  display: flex;
  flex-direction: column;
  > div {
    height: 100%;
    background: #fff;
    padding: 0 38px;
  }
}
.info_operation_btn {
  width: 100%;
  height: 50px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #eeeeee;
  > p {
    margin: 0;
    font-size: 16px;
    font-family: PingFang SC;
    font-weight: 600;
    color: #1b94fb;
  }
}
.info_content_div {
  width: 100%;
  height: calc(100% - 50px - 60px);
  box-sizing: border-box;
  overflow: auto;
  > div {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid #eeeeee;
    &:hover {
      background: #e3f6ff;
    }
    > p {
      margin: 0;
      margin-bottom: 9px;
      font-size: 16px;
      font-family: PingFang SC;
      font-weight: 600;
      line-height: 22px;
      padding-right: 10px;
      color: #333;
      &:last-child {
        display: flex;
        justify-content: space-between;
        margin-bottom: 0;
        > span {
          font-size: 12px;
          font-family: PingFangSC-Regular;
          line-height: 17px;
          color: #999;
          font-weight: normal;
        }
      }
    }
  }
}
.table_pagination {
  width: 100%;
  height: 60px;
  box-sizing: border-box;
  padding: 8px 0;
  display: flex;
  .pagination_div {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    ::v-deep .el-pagination {
      padding: 0;
      height: 30px;
      .el-pagination__sizes {
        margin: 0;
        .el-input {
          margin-right: 0;
        }
      }
    }
  }
}
</style>